#include "saleswidget.h"

#include <QDebug>
#include <QKeyEvent>


SalesWidget::SalesWidget(QWidget *parent) : QWidget(parent)
{
    // 很重要，要不然只能检测到一些功能键
    // 加入会出现错误X Error: BadWindow， 但不影响运行
    this->grabKeyboard();
}

void SalesWidget::keyPressEvent(QKeyEvent *event)
{
    switch (event->key()) {
    case Qt::Key_Delete:
        emit deletePressed();
        break;
    case Qt::Key_Asterisk:
        emit asteriskPressed();
        break;
    case Qt::Key_Return:
        emit enterPressed();
        break;
    case Qt::Key_Escape:
        emit escPressed();
        break;
    case Qt::Key_Plus:
        emit plusPressed();
        break;
    default:
        qDebug() << event->key() << "Pressed";
    }
}
